import React,{Component} from 'react';
import { withRouter } from 'react-router-dom'
import {Carousel, Icon, Menu, Modal} from "antd";
import storage from '../../utils/storage'
import memoryUtills from '../../utils/memoryUtils'
import './main-navbar-side.less'
import Avatar from '../../assets/imgs/avatar.png'

const { SubMenu } = Menu;
const { confirm } = Modal;

class MainNavbarSide extends Component{
    logout = () => {
        confirm({
            title: '确定退出吗？',
            okText: '确定',
            cancelText: '取消',
            onOk:() => {
                storage.removeUser()
                storage.removeToken()
                memoryUtills.user = ''
                setTimeout(()=>{
                    this.props.history.replace('/login')
                }, 500)
            }
        });
    }
    render(){
        return(
            <div className="main-header-sider-right">
                <Icon type="sound" style={{color: '#eeeeee',fontSize: '20px'}}/>
                <div className="notice-wrap">
                    <Carousel className="notice" autoplay dotPosition="right" dots="false">
                        <div>
                            <h3>新开客户14个</h3>
                        </div>
                        <div>
                            <h3>新开客户14个</h3>
                        </div>
                        <div>
                            <h3>新开客户14个</h3>
                        </div>
                        <div>
                            <h3>新开客户14个</h3>
                        </div>
                    </Carousel>
                </div>
                <div className="avatar-wrap">
                    <img src={Avatar} alt={Avatar}/>
                </div>
                <Menu className="user-menu" mode="horizontal">
                    <SubMenu
                        title={
                            <span className="submenu-title-wrapper">
                              xkl
                            </span>
                        }
                        >
                        <Menu.Item key="setting:1" onClick={this.logout}>退出登录</Menu.Item>
                        <Menu.Item key="setting:2">修改密码</Menu.Item>
                    </SubMenu>
                </Menu>
            </div>
        )
    }
}
export default withRouter(MainNavbarSide);